{extend name="base/index"/}

{block name="page_location"}
<div class="row">
	<div class="col-12">
		<div class="page-title-box">
			<div class="page-title-right">
				<ol class="breadcrumb m-0">
					<li class="breadcrumb-item">
						<a href="{:url('index/index')}">管理中心</a>
					</li>
					<li class="breadcrumb-item active"><i class="iconfont icon-angle-right"></i>{$model_info.model_name}列表</li>
				</ol>
			</div>
			<h4 class="page-title">
				【{$model_info.model_name}】信息管理
			</h4>
		</div>
	</div>
</div>
{/block}
{block name="body"}
<div class="row">
	<div class="col-12">
		<div class="card ">
			<div class="card-header">
				{eq name="act" value="edit"}
				<div class="caption"><i class="icon-cogs"></i>{$model_info.model_name}修改</div>
				{else/}
				<div class="caption"><i class="icon-cogs"></i>发布新{$model_info.model_name}</div>
				{/eq}
			</div>
			<div class="card-body">
				<form action="#" class="form-horizontal" id="document_edit_frm">
					<input type="hidden" name="model_id" value="{$model_id}" />
					<input type="hidden" name="doc_id" value="{$doc_id}" />
					<!--自动加载模型中相关字段-->
					{volist name="fields" id="field"}
					{switch name="field.field_type"}
					{case value="text"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-5">
							{neq name="field.verify_type" value=""}
							<input name="{$field.field_name}" value="{$field.value}" type="text" placeholder="" class="form-control ipt_check"
							 data-type="{$field.verify_type}" data-len="{$field.verify_len}" nullmsg="{$field.field_title}不能为空" errormsg="{$field.field_title}长度为{$field.verify_len}" />
							{else/}
							<input name="{$field.field_name}" type="text" placeholder="" value="{$field.value}" class="form-control" />
							{/neq}

							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="multi_text"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-5">
							{neq name="field.verify_type" value=""}
							<textarea name="{$field.field_name}" class="form-control ipt_check" data-type="{$field.verify_type}"
							 data-len="{$field.verify_len}" nullmsg="{$field.field_title}不能为空" errormsg="{$field.field_title}长度为{$field.verify_len}"
							 rows="5">{$field.value}</textarea>
							{else/}
							<textarea name="{$field.field_name}" class="form-control" rows="5">{$field.value}</textarea>
							{/neq}
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="float"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-5">
							{neq name="field.verify_type" value=""}
							<input type="text" value="{$field.value}" placeholder="" class="form-control ipt_check" data-type="{$field.verify_type}"
							 data-len="{$field.verify_len}" nullmsg="{$field.field_title}不能为空" errormsg="{$field.field_title}长度为{$field.verify_len}"
							 name="{$field.field_name}" />
							{else/}
							<input type="text" placeholder="" value="{$field.value}" class="form-control" name="{$field.field_name}" />
							{/neq}
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="radio"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-5">
							{volist name="field.node" id="node"}
							<div class="custom-control custom-radio">
								<input type="radio" name="{$field.field_name}" id="{$field.field_name}_{$node.key}" class="custom-control-input" value="{$node.key}" {eq name='$node.ischecked' value="checked" }
								 checked="checked" {/eq}>
								<label class="custom-control-label" for="{$field.field_name}_{$node.key}">{$node.value}</label>
							</div>
							{/volist}
							 <span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="checkbox"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-5">							
							{volist name="field.node" id="node"}
							<div class="custom-control custom-checkbox">
								<input type="checkbox" class="custom-control-input {$field.field_name}_{$node.key}" id="{$field.field_name}_{$node.key}"  value="{$node.key}"  name="{$field.field_name}[]" {eq name='$node.ischecked' value="checked" } checked="checked" {/eq}>
								<label class="custom-control-label" for="{$field.field_name}_{$node.key}">{$node.value}</label>
							</div>	
							{/volist}
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="list"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-5">
							<select class="form-control" tabindex="1" name="{$field.field_name}">
								{volist name="field.node" id="node"}
								<option value="{$node.key}" {eq name='$node.ischecked' value="checked" } selected="selected" {/eq}>{$node.value}
								 </option> {/volist} </select> <span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="single_image"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}：</label>
						<div class="col-10">
							{neq name="field.verify_type" value=""}
							<div class="config_uploadfile {$field.field_name} ipt_check" data-type="{$field.verify_type}"
							 attr-inputname="{$field.field_name}" nullmsg="{$field.field_title}没有上传" attr-value="{$field.value}"  isCompress="1"></div>
							{else/}
							<div class="config_uploadfile {$field.field_name}" attr-value="{$field.value}"  isCompress="1"></div>
							{/neq}
							<span class="font-13 text-muted">{$field.hint}</span>
							<script type="text/javascript">
								$(function() {
									File_Upload('.{$field.field_name}', 'image', '{$field.field_name}', false);
								});
							</script>
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="multi_image"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}：</label>
						<div class="col-10">
							<div class="config_uploadfile {$field.field_name}" attr-value="{$field.value}"  isCompress="1"></div>
							<span class="font-13 text-muted">{$field.hint}</span>
							<script type="text/javascript">
								$(function() {
									File_Upload('.{$field.field_name}', 'image', '{$field.field_name}', true);
								});
							</script>
						</div>
					</div>
					{/case}
					{case value="single_file"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}：</label>
						<div class="col-10">
							{neq name="field.verify_type" value=""}
							<div class="config_uploadfile {$field.field_name} ipt_check" data-type="{$field.verify_type}"
							 attr-inputname="{$field.field_name}" nullmsg="{$field.field_title}没有上传" attr-value="{$field.value}"></div>
							{else/}
							<div class="config_uploadfile {$field.field_name}" attr-value="{$field.value}"></div>
							{/neq}
							<span class="font-13 text-muted">{$field.hint}</span>
							<script type="text/javascript">
								$(function() {
									File_Upload('.{$field.field_name}', 'file', '{$field.field_name}', false);
								});
							</script>
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="multi_file"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}：</label>
						<div class="col-10">
							<div class="config_uploadfile {$field.field_name}" attr-value="{$field.value}"></div>
							<span class="font-13 text-muted">{$field.hint}</span>
							<script type="text/javascript">
								$(function() {
									File_Upload('.{$field.field_name}', 'file', '{$field.field_name}', true);
								});
							</script>
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="single_media"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}：</label>
						<div class="col-10">
							{neq name="field.verify_type" value=""}
							<div class="config_uploadfile {$field.field_name} ipt_check" data-type="{$field.verify_type}"
							 attr-inputname="{$field.field_name}" nullmsg="{$field.field_title}没有上传" attr-value="{$field.value}"></div>
							{else/}
							<div class="config_uploadfile {$field.field_name}" attr-value="{$field.value}"></div>
							{/neq}
							<span class="font-13 text-muted">{$field.hint}</span>
							<script type="text/javascript">
								$(function() {
									File_Upload('.{$field.field_name}', 'video', '{$field.field_name}', false);
								});
							</script>
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="multi_media"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}：</label>
						<div class="col-10">
							<div class="config_uploadfile {$field.field_name}" attr-value="{$field.value}"></div>
							<span class="font-13 text-muted">{$field.hint}</span>
							<script type="text/javascript">
								$(function() {
									File_Upload('.{$field.field_name}', 'video', '{$field.field_name}', true);
								});
							</script>
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="single_ueditor"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}：</label>
						<div class="col-10">
							<textarea id="{$field.field_name}" name="{$field.field_name}">{$field.value}</textarea>
							<script type="text/javascript">
								$(function() {
									var {$field.field_name} = UE.getEditor('{$field.field_name}', {
										serverUrl: '/static/plugin/ueditor/php/controller.php',
										toolbars: Get_UEditor_Config('single')
									});
									//导入word
									{eq name = "Config.swword2html" value = "1"}
									File_Upload('.wordfile', 'file', 'wordfile', false);
									$(".import_btn").click(function() {
										var src = $(this).attr('attr-src');
										var dst = $(this).attr('attr-dst');
										var Path = $("input[name='" + src + "']");
										if (Path.val() == "") {
											layer.msg('请先上传Word/Excel文件');
											return false;
										}
										var index = layer.load();
										$.getJSON("{:url('document/WordToHtml')}", {
											'path': Path.val()
										}, function(result) {
											if (result.status == 0) {
												{$field.field_name}.setContent(result.data);
											} else {
												layer.msg(result.msg);
											}
											layer.close(index);
										});
									}); 
									{/eq}
								});
							</script>
							{eq name="Config.swword2html" value="1"}
							<div style="margin-top: 6px;display: inline-block;" class="config_uploadfile wordfile" attr-value=""></div>
							<span class="font-13 text-muted">
								<a href="javascript:;" class="btn btn-success btn-sm import_btn" attr-src="wordfile" attr-dst="{$field.field_name}">导入Word/Excel文件</a>
							</span>
							{/eq}
						</div>
					</div>
					{/case}
					{case value="full_ueditor"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}：</label>
						<div class="col-10">
							<textarea id="{$field.field_name}" name="{$field.field_name}">{$field.value}</textarea>
							<script type="text/javascript">
								$(function() {
									var {$field.field_name} = UE.getEditor('{$field.field_name}', {
										serverUrl: '/static/plugin/ueditor/php/controller.php',
										toolbars: Get_UEditor_Config('full')
									});
									//导入word
									{eq name = "Config.swword2html" value = "1"}
									File_Upload('.wordfile', 'file', 'wordfile', false);
									$(".import_btn").click(function() {
										var src = $(this).attr('attr-src');
										var dst = $(this).attr('attr-dst');
										var Path = $("input[name='" + src + "']");
										if (Path.val() == "") {
											layer.msg('请先上传Word/Excel文件');
											return false;
										}
										console.log(Path.length);
										var index = layer.load();
										$.getJSON("{:url('document/WordToHtml') }", {
											'path': Path.val()
										}, function(result) {
											if (result.status == 0) {
												{$field.field_name}.setContent(result.data);
											} else {
												layer.msg(result.msg);
											}
											layer.close(index);
										});
									}); 
									{/eq}
								});
							</script>
							{eq name="Config.swword2html" value="1"}
							<div style="margin-top: 6px;display: inline-block;" class="config_uploadfile wordfile" attr-value=""></div>
							<span class="font-13 text-muted">
								<a href="javascript:;" class="btn btn-success btn-sm import_btn" attr-src="wordfile" attr-dst="{$field.field_name}">导入Word/Excel文件</a>
							</span>
							{/eq}
						</div>
					</div>
					{/case}
					{case value="baidu_map"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-10">
							<input type="text" placeholder="可以手动输入" name="{$field.field_name}" class="form-control" value="{$field.value}" />
							<a href="javascript:;" class="btn blue icn-only baidumap_ipt_btn" attr-bind="{$field.field_name}"><i class="icon-map-marker user white"></i></a>
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					<script type="text/javascript">
					$(function(){
						$(".baidumap_ipt_btn").click(function() {
							var bind = $(this).attr('attr-bind');
							var type = 'address';
							var porints = Show_BaiduMap('{$Config.defaultbaidumaparea}', '', '', bind, type);
						});						
					});
					</script>
					{/case}
					{case value="color"}
					<script type="text/javascript">
						$(function() {
							$("input[name='{$field.field_name}']").minicolors({
								theme: 'bootstrap'
							});
						});
					</script>
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-10">
							<input type="text" name="{$field.field_name}" class="form-control" value="{$field.value}">
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="area"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-10">
							<select class="small m-wrap" tabindex="1" name="{$field.field_name}_p"></select>
							<select class="small m-wrap" tabindex="1" name="{$field.field_name}_c"></select>
							<select class="small m-wrap" tabindex="1" name="{$field.field_name}_a"></select>
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					<script type="text/javascript">
						new PCAS("{$field.field_name}_p", "{$field.field_name}_c", "{$field.field_name}_a", "吉林省", "白城市", "大安市");
					</script>
					{/case}
					{case value="datetime"}
					<script type="text/javascript">
						$(function() {
							$("input[name='{$field.field_name}']").cxCalendar({
								type: 'datetime',
								format: 'YYYY-MM-DD HH:mm:ss'
							});
						});
					</script>
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-5">
							<input type="text" name="{$field.field_name}" class="form-control" value="{$field.value}">
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="hidden"}
					<input type="hidden" name="{$field.field_name}" value="{$field.value}" />
					{/case}
					{case value="class"}
					<div class="form-group row mb-1">
						<label class="col-2 col-form-label">{$field.field_title}:</label>
						<div class="col-5">
							<select class="form-control" tabindex="1" name="{$field.field_name}">
								{$field.node}
							</select>
							<span class="font-13 text-muted">{$field.hint}</span>
						</div>
					</div>
					{/case}
					{case value="orderid"}
                    <div class="form-group row mb-1">
                        <label class="col-2 col-form-label">{$field.field_title}:</label>
                        <div class="col-5">
							<input type="number" name="{$field.field_name}" class="form-control small" value="{$field.value}">
							<span class="font-13 text-muted">{$field.hint}</span>
                        </div>
					</div>
					{/case}
					{default /}
					{/switch}
					{/volist}				
				</form>
			</div>
			<div class="card-footer text-muted">
				<div class="form-group row mb-1">
					<label class="col-2 col-form-label"></label>
					<div class="col-5">
						<button type="button" class="btn btn-primary Fast_Form_Post" attr-frm="#document_edit_frm" attr-callback="back" attr-model="{$model_name}"
					 attr-active="doc_save">立即提交</button>
					</div>
				</div>	
			</div>
		</div>
	</div>
</div>
{/block}
{block name="script"}
<!--选择性加载相关插件-->
{volist name="fields_types" id="type"}
{switch name="type"}
{case value="ueditor"}
<script src="__PLUGIN__/ueditor/ueditor.config.js" type="text/javascript"></script>
<script src="__PLUGIN__/ueditor/ueditor.all.min.js" type="text/javascript"></script>
{/case}
{case value="baidu_map"}
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak={$Config.baidumap_ak}"></script>
{/case}
{case value="color"}
<script type="text/javascript" src="__PLUGIN__/minicolors/jquery.minicolors.min.js"></script>
<link rel="stylesheet" href="__PLUGIN__/minicolors/jquery.minicolors.css" />
{/case}
{case value="area"}
<script type="text/javascript" src="__PLUGIN__/PCAS/PCASClass.js"></script>
{/case}
{case value="datetime"}
<script type="text/javascript" src="__PLUGIN__/jQuery.cxCalendar/js/jquery.cxcalendar.min.js"></script>
<script type="text/javascript" src="__PLUGIN__/jQuery.cxCalendar/js/jquery.cxcalendar.languages.js"></script>
<link rel="stylesheet" href="__PLUGIN__/jQuery.cxCalendar/css/jquery.cxcalendar.css" />
{/case}
{default /}
{/switch}
{/volist}
{/block}
